All Questions
15 questions
0votes
1answer
368views
How best to share common steps between services while allowing them to provide their own behaviour
I've started working on a C# codebase. There are three services which run the same set of steps of three kinds of objects, each returning IResult: public IResult FooService(Foo foo) { ... } public ...
1vote
2answers
1kviews
Calling methods on objects VS. passing objects as parameters
Which is considered a generally accepted practice? class Image { public void decode(); }; //main Image image; image.decode(); vs class ImageDecoder { public Image run(Image image); }; //main Image ...
1vote
1answer
907views
Can a class factory also save the object to a database?
How can a factory also save the object in the database? I want to create an object that consists of other objects. Pseudocode: firstObject = db.get....; secondObject = db.get....; expectedObject = ...
4votes
4answers
539views
Is it better to generate a large list during the constructor or when it's accessed?
I've got a class member function that generates a large list and puts it into a private member variable so it can be accessed through a getter. The generation of this list is a rather intensive ...
5votes
2answers
8kviews
Design pattern for processing a huge CSV file -- Java
I am learning design patterns in Java and also working on a problem where I need to handle huge number of requests streaming into my program from a huge CSV file on the disk. Each CSV line is one ...
65votes
10answers
36kviews
Do you generally send objects or their member variables into functions?
Which is generally accepted practice between these two cases: function insertIntoDatabase(Account account, Otherthing thing) { database.insertMethod(account.getId(), thing.getId(), thing....
3votes
2answers
3kviews
Using MVC style, where is the best place to put SQL functionality?
I am wondering about best practices here. MVC (Model - View - Controller) patterns involve separating components of your program that model the data, manipulate those models, and display those ...
2votes
1answer
639views
Should all functions be fully self-contained (is it bad practice to share a variable between functions)?
There are two ways to do the same thing (pseudo code) Define databaseHandle in the parent function, and use it as a global in this scope: function API() { function openDatabase() { return ...
2votes
1answer
274views
Is it OK to deprecate methods that need to be public due to the packaging model but are not to be used outside the codebase in Java?
I am currently working on a semi-large project that has several packages. There are 3 main packages, a "client" package, a "server" package and a "common" package. There are two jars, one for the ...
3votes
3answers
287views
Development Time: sql in UI code vs domain model with datamapper
First, sorry for my English guys. Currently this is my first programming job. I am labeled as the most incompetent programmer in my company that's because they measure the performance and ...
1vote
1answer
191views
How to deal with interactions between many objects
I've been working on a game in my spare time. I'm pretty much done defining the primitives and until today everything was pretty well segmented and encapsulated but now it's come time to implement ...
3votes
3answers
2kviews
Parallel Class/Interface Hierarchy with the Facade Design Pattern?
About a third of my code is wrapped inside a Facade class. Note that this isn't a "God" class, but actually represents a single thing (called a Line). Naturally, it delegates responsibilities to the ...
21votes
5answers
2kviews
How to avoid giant glue methods?
In my current job, I've been tasked with cleaning up old code a few times. Often the code is a labyrinth and the data behind it is even more tangled. I find myself combing out things into nice, neat,...
1vote
6answers
5kviews
Learning good OOP design and unlearning some bad habits [duplicate]
Possible Duplicate: What books or resources would you recommend to learn practical OO design and development concepts? I have been mostly a C programmer so far in my career with knowledge of C++. ...
9votes
5answers
1kviews
When to stop inheritance?
Once upon time ago I asked a question on Stack Overflow about inheritance. I have said I design chess engine in OOP fashion. So I inherit all my pieces from Piece abstract class but inheritance still ...